;; EX-13.scm - Standard Schroeder reverberator
 
;; A compound UGen implementing a standard Schroeder reverberator.
;; `Input' is the input audio signal, `reverbTime' and `gain' are
;; control inputs.

(define-procedure (SchroederReverb.ar (in 0) (reverbTime 0.1) (gain 1))
  (AllpassN.ar 
   (AllpassN.ar
    (Mix (CombN.ar in 0.05 '(0.0297 0.0371 0.0411 0.0437) reverbTime 1/4))
    0.01 0.005 0.096835)
   0.01 0.0017 0.032924 gain))

(SchroederReverb.ar (WhiteNoise.ar (Decay2.ar (Impulse.ar 1/2 0 0.3) 0.01 0.3))
		    reverbTime: 2)

(define (with-reverb in reverbTime reverbGain)
  (Add (SchroederReverb.ar in reverbTime reverbGain) in))

(synthdef-send
 (synthdef
  "Test"
  ((reverbTime 0.1) (reverbGain 1))
  (Out.ar 0 (with-reverb
	     (WhiteNoise.ar (Decay2.ar (Impulse.ar 1 0 0.3) 0.01 0.3))
	     reverbTime
	     reverbGain))))

(-> "/s_new" "Test" -1 1 1)

(-> "/n_set" -1 "reverbTime" 4 "reverbGain" 0.25)

(-> "/g_freeAll" 1)
